<%-- 
    Document   : searchForm
    Created on : Jan 2, 2013, 7:15:06 PM
    Author     : berto
--%>

<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.items.Product"%>
<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.DBManager"%>
<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.items.Category"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

<%!
   private String srcCategory;
   public void jspInit(){
            DBManager db=(DBManager)super.getServletContext().getAttribute("db_manager");
            ArrayList<Category> listCat=db.getCategories();
            srcCategory="<select name=\""+Product.CATEGORY+"\">";
            for(Category c:listCat){
                srcCategory=srcCategory+"<option value=\""+c.getId()+"\" >"+c.getName()+"</option>";
            }
            srcCategory=srcCategory+"<option value=\""+0+"\" >"+"Tutte le Categorie"+"</option>";
                    
            srcCategory=srcCategory+ "</select>";   
  }
%>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Search form</title>
    </head>
    <body>
        <h3>Select the parameter of your search</h3>
                <form name="searchProduct" method="post"
                action="<%=response.encodeURL(request.getContextPath()+"/contents/user/searchProduct")%>" >
                <table>
                    <tr>
                        <td><label>Category:</label></td>
                        <td>
                            <label>Search:</label>
                        </td>
                        <td><label>Seller:</label></td>
                        <td><input type="reset" name="reset" value="Reset" class="button"/></td>
                    </tr>
                    <tr>
                        <td>
                            <%=srcCategory%>
                        </td>
                        <td><input type="text" name="ricerca"
                                   value="<%=request.getParameter("ricerca")==null? "":request.getParameter("ricerca")%>"/></td>
                        
                        <td><input type="text" name="seller"
                                   value="<%=request.getParameter("seller")==null? "":request.getParameter("seller")%>"/><label></label></td>
                        
                        
                        <td><input type="submit" name="Search" class="button" value="Search"/></td>
                    </tr>
                </table>
                </form>
    </body>
</html>
